#include "dominion.h"
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>

// testing isGameOver()



int main() {
	struct gameState *G = newGame();

	// Set random val to r
	srand(time(NULL));
	int r = rand();

	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};
	initializeGame(2, k, r, G);
 	
	// Test case for if we have expended the province cards 
	printf("Testing if game will stop when province is gone.");
	G->supplyCount[province] = 0;
	assert(isGameOver(G) == 1);
	printf("Test Passed.\n");

	// Reset provinces and make sure old state is restored
	printf("Testing if game will be running if all resources are there.\n");
	G->supplyCount[province] = 8;
	assert(isGameOver(G) == 0);
	printf("Test Passed.\n");

	printf("Testing while eliminating all resources 1 at a time.\n");
	// test while eliminating all resourves
	int i;
	for(i = 0; i <= gold; i++) 
	{
		G->supplyCount[i] = 0;
		if(i < 2)
		{
			assert(isGameOver(G) == 0);
		}
		else
		{
			assert(isGameOver(G) == 1);
		}

	}
	// eliminating all playable cards
	for(i = 0; i < 10; i++)
	{
		G->supplyCount[k[i]] = 0;
		assert(isGameOver(G) == 1);
	}
	printf("Test Passed.\n");
	printf("All Tests Passed.\n");
	return 0;
		
}
